package com.formula.propertyshop.view.phone;

import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.formula.propertyshop.R;
import com.formula.propertyshop.adapter.BSDCalculatorPageAdapter;
import com.formula.propertyshop.view.common.BSDCalculatorMenuBar;
import com.formula.propertyshop.view.common.BaseActivity;

public class BSDCalculator extends BaseActivity {

	private BSDCalculatorPageAdapter pageAdapter;
	ViewPager mViewPager;
	BSDCalculatorMenuBar menuBar;
	@Override
	protected void initUI() {
		setContentView(R.layout.main_bsd_calculator);
		TextView title = (TextView) findViewById(R.id.txtTitle);
		title.setText(getString(R.string.calculation));
		pageAdapter = new BSDCalculatorPageAdapter(getSupportFragmentManager());
		menuBar = (BSDCalculatorMenuBar) findViewById(R.id.bsd_top_menu);
		menuBar.initUI();
		menuBar.setButtonActive(0);
        // Set up the ViewPager, attaching the adapter and setting up a listener for when the
        // user swipes between sections.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(pageAdapter);
        mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                // When swiping between different app sections, select the corresponding tab.
                // We can also use ActionBar.Tab#select() to do this if we have a reference to the
                // Tab.
                menuBar.setButtonActive(position);
            }
        });
        menuBar.getBtnBSD().setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mViewPager.setCurrentItem(0);
			}
		});
        menuBar.getBtnABSD().setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mViewPager.setCurrentItem(1);
				}
		});
    }
	
}
